how get the user show mvc controller core 3.1

95

how get the user show mvc controller core 3.1 -

string userName = _httpContextAccessor.HttpContext.User.Identity.Name;

how get the user show mvc controller core 3.1 -

public string LoggedInUser => User.Identity.Name;

how get the user show mvc controller core 3.1 -

services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

how get the user show mvc controller core 3.1 -

private readonly IHttpContextAccessor _httpContextAccessor;
//constructor then
_httpContextAccessor = httpContextAccessor;

Comments

Submit
0 Comments